import type { CartItem } from '@/types/cart'
import { http } from '@/utils/http'
/**
 * 加入购物车
 * @param data 请求体参数
 */
export const addMemberCart = (data: {
  itemSaleChannelId: number
  itemSaleSkuId: number
  number: number
}) => {
  return http({
    method: 'POST',
    url: '/api/memberCart/addMemberCart',
    data,
  })
}

/**
 * 获取购物车列表
 */
export const listMemberCart = () => {
  return http<CartItem[]>({
    method: 'GET',
    url: '/api/memberCart/listMemberCart',
  })
}

/**
 * 删除/清空购物车单品
 * @param data 请求体参数 ids SKUID 集合
 */
export const deleteMemberCart = (ids: string) => {
  return http({
    method: 'POST',
    url: '/api/memberCart/deleteMemberCart?ids=' + ids,
  })
}

/**
 * 修改购物车单品
 * @param data itemSaleSkuId SKUID number 商品数量
 */
export const updateMemberCart = (data: {
  itemSaleChannelId: number
  itemSaleSkuId: number
  number?: number
}) => {
  return http({
    method: 'POST',
    url: `/api/memberCart/updateMemberCart`,
    data,
  })
}
